package com.example.demo.mongodb;

import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName SysUserController
 * @Description:
 * @Author liyunjiang
 * @Date 2020/5/17 15:59
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    SysUserService userService;

    @PostMapping("/add")
    public void insert(@RequestBody SysUser user) {
        userService.insert(user);
    }

    @GetMapping("/list")
    public List<SysUser> list(){
        return userService.list();
    }

    @DeleteMapping("/delete/{id}")
    public String delete(@PathVariable String id){
        userService.delete(id);
        return "ok";
    }
    @GetMapping("/findById/{id}")
    public SysUser findById(@PathVariable int id){
        return userService.findById(id);
    }
}
